<?php
require_once "../../config.php";
require_once "../../functions.php";
//获取用户的头像和昵称，返回给前端,动态生成我们的头像
session_start();
// print_r($_SESSION);
$userId = $_SESSION['user_id'];
$connect = connect();
$sql = "select * from users where id = {$userId}";
$queryResult = query($connect,$sql);
$response = ["code"=>0,"msg"=>"操作失败"];
if($queryResult){
    $response["code"] = 1;
    $response["msg"] = "操作成功";
    $response["avator"] = $queryResult[0]["avatar"];
    $response["nickname"] = $queryResult[0]["nickname"];
}
header('content-type:application/json;charset=utf8');
echo json_encode($response);
?>